package utils;

public class Matrix 
{
	public static Integer[][] transpose(Integer[][] matrix)
	{
		Integer[][] transposed = new Integer[matrix.length][matrix.length];
		
		// copying
		for(int i = 0; i < matrix.length; i++)
		{
			for(int j = 0; j < matrix.length; j++)
			{
				transposed[j][i] = matrix[i][j];
			}
		}
		
		return transposed;
	}
	
	public static int[] asapPriorities(Integer[][] graph)
	{
		int[] length = new int[graph.length];
		for(int i = 0; i < length.length; i++)
		{
			length[i] = 0;
		}
		
		// for each vertex
		for(int i = 0; i < graph.length; i++)
		{
			// for each edge
			for(int j = 0; j < graph[i].length; j++)
			{
				if(graph[i][j] != null && i != j && length[j] < length[i] + graph[i][j] + graph[i][i])
				{
					length[j] = length[i] + graph[i][j] + graph[i][i];
				}
			}
		}
		return length;
	}
}
